package com.ruoyi.demo.controller.app;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.demo.domain.AuctionRule;
import com.ruoyi.demo.service.IAuctionRuleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(tags = "小程序-竞拍规则")
@RestController
@RequestMapping("/app/rule")
public class AppAuctionRuleController extends BaseController {
    @Autowired
    private IAuctionRuleService auctionRuleService;

    @ApiOperation("查询竞拍规则列表")
    @GetMapping("/list")
    public TableDataInfo list(AuctionRule auctionRule) {
        startPage();
        List<AuctionRule> list = auctionRuleService.selectAuctionRuleList(auctionRule);
        return getDataTable(list);
    }

    @ApiOperation("获取竞拍规则详细信息")
    @GetMapping(value = "/{ruleId}")
    public AjaxResult getInfo(@PathVariable("ruleId") Long ruleId) {
        return success(auctionRuleService.selectAuctionRuleByRuleId(ruleId));
    }

    @ApiOperation("新增竞拍规则")
    @Log(title = "竞拍规则", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AuctionRule auctionRule) {
        return toAjax(auctionRuleService.insertAuctionRule(auctionRule));
    }

    @ApiOperation("修改竞拍规则")
    @Log(title = "竞拍规则", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AuctionRule auctionRule) {
        return toAjax(auctionRuleService.updateAuctionRule(auctionRule));
    }

    @ApiOperation("删除竞拍规则")
    @Log(title = "竞拍规则", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ruleIds}")
    public AjaxResult remove(@PathVariable Long[] ruleIds) {
        return toAjax(auctionRuleService.deleteAuctionRuleByRuleIds(ruleIds));
    }
} 